
#include<bits/stdc++.h>
using  namespace std;
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    vector<int> vec = {k};
    for(int i = 1;i <= n;++i){
        vector<int> nxt;

        for(auto x:vec){
            nxt.push_back(x/2);
            nxt.push_back((x+1)/2);
        }

        vec = nxt;
    }
    puts(k%(1<<n) ? "1" : "0");
    for(auto x:vec) printf("%d ",x);
    return 0;
}